<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ include file="/parameter.jsp" %>
<html>
<head>
	<title>后台管理</title>
	<%@ include file="/admin/adminParam.jsp" %>
</HEAD>
<body>
<div class="statusBar"></div>
<iframe id="hidden1" name="checkusername" allowtransparency="false" frameborder="0" style="height:0;width:0"></iframe>
<form name="registerForm" id="registerForm" method="post" action="adminAction.do?method=UserManagerAddDo" enctype="multipart/form-data" onSubmit="return Validator.Validate(this, 3)">
<table align="center" width="80%" border="0" cellspacing="10" cellpadding="0" class="table">  
  <tr>
    <td align="right" width="20%">用户级别：</td>
    <td><select name="usergrade" onChange="">
    	<option value="0">管理员</option>
    	<!--option value="1" <c:if test="${user.sex == '1'}">selected</c:if>>版主</option-->
    	<option value="2" selected>普通用户</option>
        </select>
    </td>
    <td align="left" width="40%"></td>
  </tr> 
  <tr>
    <td align="right" width="20%">用户名：</td>
    <td><input type="text" class="input2" name="username" size="20" maxlength="20" value="" title="请填写用户名！" onBlur="checkUser();" datatype="Require" msg="必须填写"><div id="info"></div></td>
    <td align="left" width="40%">不能有空格，可以是中文，长度在 6 字节以上</td>
  </tr>
  <tr>
    <td align="right">密码：</td>
    <td><input type="password" class="input2" name="password" size="20" maxlength="20" value="" title="请输入密码！" datatype="Require" msg="必须填写"></td>
    <td align="left" width="40%">英文字母或数字等不少于6位</td>
  </tr>
  <tr>
    <td align="right">确认密码：</td>
    <td><input type="password" class="input2" name="repwd" size="20" maxlength="20" value="" title="请确认密码！" datatype="Require" msg="必须填写"></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
  	<td align="right" width="20%">邮件地址：</td>
	<td><input type="text" class="input2" name="email" size="50" maxlength="50" value="" title="请填写邮件地址！" datatype="Require" msg="必须填写"></td>
	<td align="left" width="40%"></td>
  </tr>
  <tr>
    <td align="right" width="20%">昵称：</td>
    <td><input type="text" class="input2" name="nickname" size="20" maxlength="20" value="" title="请填写昵称！" datatype="Require" msg="必须填写"></td>
    <td align="left" width="40%"></td>
  </tr>
  <tr>
    <td align="right" width="20%">性别：</td>
    <td><select name="sex" onChange="">
            <option value="保密">保密</option>
			<option value="帅哥">帅哥</option>
			<option value="美女">美女</option>
        </select></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="right">生日：</td>
    <td><select name="year" onChange="changeDate();"><!--注意:考虑到润年的关系,这里也要加上onchange事件-->
<%
for(int i=1940;i<2100;i++){
   out.print("<option value=\""+i+"\">"+i+"</option>");
}
%>
</select>年
<select name="month" onChange="changeDate();">
<%
for(int i=1;i<13;i++){
   out.print("<option value=\""+i+"\">"+i+"</option>");
}
%>
</select>月
<select name="day">
</select>日</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
  	<td align="right">自定义头像：</td>
	<td id="pho"><input type="file" name="portrait" size="50" class="input2" alt="用户上传头像！"></td>
	<td>用户可以上传自己喜爱的图片作为头像。用户上传文件后不能再更改！</td>
  </tr>
</table>
<table align="center" width="80%" border="0" cellspacing="10" cellpadding="0">
  <tr>
  	<td width="20%"></td>
  	<td width="30%" align="center"><input type="submit" value="提 交" /></td>
  	<td width="20%"></td>
  </tr>
</table>
</form>
</body>
<script language="javascript">
function checkUser(){
	var name = registerForm.username.value;
	if(name != null && name != ""){
	document.frames["hidden1"].location = "adminAction.do?method=CheckUsername&username=" + registerForm.username.value;
	}else{
		alert("请先输入用户名!");
		return false;
	}
}
function changeDate(){
  var days = getMonthDays(document.registerForm.year.value,document.registerForm.month.value); //取得当前月应该有多少天
  var obj = document.registerForm.day;  //取得日期Select容器
  var lastValue = obj.value;  //记录用户选择的值
  if(lastValue*1 > days)lastValue = days;
  if(!lastValue)lastValue=1;
  while(obj.options.length>0) //清空日期选择框
obj.options.remove(0);
  for (var i=1; i<=days; i++)  //添加日期选项
obj.options.add(new Option(i,i));
  obj.value = lastValue;  //恢复用户选择的值
}

//获取指定月份的天数
function getMonthDays(year,month)
{
var d = new Date(year,month-1,1);
var returnValue = 0;
for(;d.getMonth()==month-1;d.setTime(d.getTime()+86400000))returnValue++;
	return returnValue;
}
changeDate(); //初始化日期选择框
</script>
</HTML>